// 引入api接口文件
import {reqCategoryList,reqBannerList,reqFloorList} from '@/api'

// import listContainer from './listContainer'
// home模块的小仓库
const state = {
    //三级分类数据
    categoryList:[],
    //轮播图数据
    bannerList:[],
    // 不能够获得 bannerList
    // bannerList:listContainer.state.bannerList

    //楼层组件数据 
    floorList:[]
}
const actions = {
    async categoryList({commit}){
        const result = await reqCategoryList()
        if(result.code===200){
            commit('CATEGORYLIST',result.data)
        }
    },
    async bannerList({commit}){
        const result = await reqBannerList()
        if(result.code===200){
            commit('BANNERLIST',result.data)
        }
    },
    async floorList({commit}){
        const result = await reqFloorList()
        if(result.code===200){
            commit('FLOORLIST',result.data)
        }
    }
}
const mutations ={
    CATEGORYLIST(state,value){
        //将数据写入state
        state.categoryList = value
        // 数据库多了一行数据
        state.categoryList.length = 16
    },
    BANNERLIST(state,value){
        state.bannerList = value
    },
    FLOORLIST(state,value){
        state.floorList = value
    }
}
const getters = {}

export default {state,actions,mutations,getters}